package chai.ningning.dev;

import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.ServletRequest;

/**
 * 	通过继承 GenericServlet 类 开发一个Servlet类
 */
public class UniversalServlet extends GenericServlet{

	private static final long serialVersionUID = 1L;

	@Override
	public void service(ServletRequest req, ServletResponse resp) 
			throws ServletException, IOException {
		
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter out = resp.getWriter();
		
		out.println("<html>");
		out.println("<head>");
		// 指定href时按照 "/applicationPath/resourcePath" 方式指定，比如 "/core/styles/universal.css"
			out.println("<link rel='stylesheet' href='/core/style/universal.css'>");
		out.println("</head>");
		out.println("<body>");
		for(int i=0;i<5;i++) {
			out.println("<div class='wrapper'>");
				out.println(LocalDateTime.now());
			out.println("</div>");
		}
		out.println("</body>");
		out.println("</html>");
	}
}
